﻿@{
    ViewBag.Title = "Update";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section inlinestyle{

    form.cmxform label.error {
        text-align: left;
        color: red;
        font-style: italic;
        font-size: 12px;
    }

    form.cmxform label {
        text-align: right;
    }
}
<form class="cmxform" autocomplete="off" method="post" action="@Url.Action("Update")">
@Html.AntiForgeryToken()
	<div class="row">
        <div class="span2">
        	<label for="update_OldPassword">旧密码：</label>
        </div>
        <div class="span4">
		    <input id="update_OldPassword" name="oldPassword" class="span6" type="password" />
        </div>
	</div>
	<div class="row">
        <div class="span2">
        	<label for="update_Password">密码：</label>
        </div>
        <div class="span4">
		    <input id="update_Password" name="password" class="span6" type="password" />
        </div>
	</div>
	<div class="row">
        <div class="span2">
        	<label for="update_ConfirmPassword">确认密码：</label>
        </div>
        <div class="span4">
		    <input id="update_ConfirmPassword" name="confirmPassword" class="span6" type="password" />
        </div>
	</div>
	<div class="row">
		<input class="btn" id="signupsubmit" name="signup" type="submit" value="提交" />
	</div>
</form>

@section links {
    <link rel="stylesheet" href="~/Content/bootstrap/css/bootstrap.css" />
}

@section scripts {
    @Scripts.Render("~/bundles/js/jquery_form_validate")
<script type="text/javascript">
    $(function () {
        // validate signup form on keyup and submit
        var validator = $(".cmxform").validate({
            rules: {
                oldPassword: {
                    required: true
                },
                password: {
                    required: true,
                    rangelength: [4, 16]
                },
                confirmPassword: {
                    required: true,
                    rangelength: [4, 16],
                    equalTo: "#update_Password"
                }
            },
            messages: {
                oldPassword: {
                    required: "请输入旧密码"
                },
                password: {
                    required: "请输入新密码",
                    rangelength: $.format("密码长度必须介于{0}和{1}之间")
                },
                confirmPassword: {
                    required: "请再输入新密码",
                    rangelength: $.format("密码长度必须介于{0}和{1}之间"),
                    equalTo: "两次输入的密码不匹配"
                }
            },
            // the errorPlacement has to take the table layout into account
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            // specifying a submitHandler prevents the default submit, good for the demo
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    success: function () {
                        alert("修改成功");
                        $(form).resetForm();
                    },
                    error: function (xhr) {
                        alert(xhr.responseText);
                    }
                });
            }
        });
    });
</script>
} @* end section scripts  *@

